package com.li.onjava8.concurrent.pl;

import java.util.Arrays;

/**
 * @author li
 * @date 2023/10/30 10:26
 */
public class Summing4 {
    public static final int SZ = 10_000_000;
    public static final long CHECK = (long)SZ * ((long)SZ + 1)/2;

    public static void main(String[] args) {
        Long[] arr = new Long[SZ + 1];
        Arrays.parallelSetAll(arr, i -> (long)i);
        Summing.timeTest("Long Array Stream Parallel Reduce", CHECK, () -> Arrays.stream(arr).parallel().reduce(0L, Long::sum));
    }
}
